package com.xin.controller;

import com.xin.entity.UserAccountEntity;
import com.xin.service.LoginService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;
import java.util.Objects;

@RestController

public class HelloController {
    @Resource
    private LoginService loginService;
    @GetMapping("/hello")
//    @PreAuthorize("hasAuthority('test')")
    @PreAuthorize("hasAuthority('test')")
    public String test01(){
        return "hello world";
    }

    @PostMapping("/hello/login")
    public Map<String, Object> login(@RequestBody UserAccountEntity userAccountEntity){
        System.out.println("???????????????????");
        System.out.println("访问前");
        return this.loginService.userLogin(userAccountEntity);


    }
}
